home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Memphis Amiga Group / MAG Disk (1989-11)(Memphis Amiga Group).zip / MAG Disk (1989-11)(Memphis Amiga Group).adf / HeadClean / disk_support < prev    next >
Text File  |  1986-11-06  |  2KB  |  96 lines

  1. \ Support for Amiga Trackdisk Driver
  2. \
  3. \ Author: Phil Burk
  4. \
  5. \ This file is hereby placed in the Public Domain and may be
  6. \ freely distributed.
  7.  
  8. getmodule includes
  9. include? UNIT ji:exec/devices.j
  10. include? TD_MOTOR ji:devices/trackdisk.j
  11. include? CreatePort() ju:exec_support
  12.  
  13. ANEW TASK-DISK_SUPPORT
  14.  
  15. 2 constant NUMHEADS
  16.  
  17. : DoIO()? ( req -- , report error if bad )
  18.     DoIO() ?dup
  19.     IF ." Error in DoIO() = " . cr
  20.     THEN
  21. ;
  22.  
  23. : TD.MOTOR ( new_state diskreq -- old_state , turn motor on or off )
  24.     dup>r
  25.     .. iotd_req ..! io_length
  26.     TD_MOTOR r@ .. iotd_req ..! io_command
  27.     r@ DoIO()?
  28.     r> .. iotd_req ..@ io_actual
  29. ;
  30.  
  31.  
  32. : TD.HC>SECTOR ( head cyl -- sector , calc sector index for cyl)
  33.     NUMHEADS * +
  34.     NUMSECS *
  35. ;
  36. : TD.SHC>OFFSET ( sector head cyl -- byte_offset )
  37.     td.hc>sector +
  38.     TD_SECTOR *
  39. ;
  40.  
  41. : TD.READ  ( rel_buffer #sectors sector# req -- error , read data from disk )
  42.     >r
  43.     TD_SECTOR * r@ .. iotd_req ..! io_offset
  44.     TD_SECTOR * r@ .. iotd_req ..! io_length
  45.     >abs r@ .. iotd_req ..! io_data
  46.     ETD_READ r@ .. iotd_req ..! io_command
  47.     r> DoIO()
  48. ;
  49.  
  50. : TD.READ?  ( rel_buffer #sectors sector# req -- , read data from disk )
  51.     td.read ?dup
  52.     IF ." Error in disk read " = . cr
  53.     THEN
  54. ;
  55.  
  56. : TD.FORMAT ( rel_buffer track req -- , format a track )
  57.     >r
  58.     NUMSECS * TD_SECTOR * r@ .. iotd_req ..! io_offset
  59.     NUMSECS TD_SECTOR * r@ .. iotd_req ..! io_length
  60.     >abs r@ .. iotd_req ..! io_data
  61.     TD_FORMAT r@ .. iotd_req ..! io_command
  62.     r> DoIO()?
  63. ;
  64.     
  65. : TD.STATUS ( status_code req -- value )
  66.     tuck .. iotd_req ..! io_command
  67.     dup DoIO()?
  68.     .. iotd_req ..@ io_actual
  69. ;
  70.  
  71. : TD.CHANGENUM ( diskreq -- value , get status and update req )
  72.     TD_CHANGENUM over td.status ( -- req val )
  73.     dup rot .. iotd_req ..! iotd_count
  74. ;
  75.     
  76. : TD.CREATE ( -- diskport diskreq | 0 , create a trackdisk request )
  77.     0 0 createport() ( -- port )
  78.     dup
  79.     IF  dup  sizeof() ioextTD createextio()  ( -- port req )
  80.         dup 0=
  81.         IF drop deleteport() 0  ( Couldn't create ext io )
  82.              ." Couldn't Create Ext IO" cr
  83.         THEN
  84.     THEN
  85. ;
  86.  
  87. : TD.OPEN ( unit diskreq -- error )
  88.    0" trackdisk.device" -rot ( -- name unit req )   
  89.    0  opendevice()
  90. ;
  91.  
  92. : TD.DELETE ( diskport diskreq -- )
  93.     sizeof() ioextTD deleteextio()
  94.     deleteport()
  95. ;
  96.